<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet"
	th:href="@{/manager/layui/lib/layui-v2.5.5/css/layui.css}"
	href="../../lib/layui-v2.5.5/css/layui.css" media="all">
<link rel="stylesheet" th:href="@{/manager/layui/css/public.css}"
	href="../../css/public.css" media="all">
<style>
body {
	background-color: #ffffff;
}
</style>
</head>
<body>
		<div class="layui-form layuimini-form">
			<input type="hidden" name="parentId" th:value="${group.parentId}"> <input
				type="hidden" name="id" th:value="${group.id}">
			<div class="layui-form-item">
				<label class="layui-form-label required">分组名称</label>
				<div class="layui-input-inline">
					<input type="text" name="name" lay-verify="required"
						lay-reqtext="分组名称不能为空" placeholder="请输入分组名称"  th:value="${group.name}"
						class="layui-input">

				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label required">类型</label>
				<div class="layui-input-inline">
					<input type="radio" name="type" th:if="${group.type == 1}" value="1"
						title="部门" checked> <input type="radio" name="type"
						th:if="${group.type == 2}" value="2" title="科室" checked>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label required">状态</label>
				<div class="layui-input-inline">
					<input type="radio" name="status" value="0" title="正常"  th:field="${group.status}">
					<input type="radio" name="status" value="1" title="禁用"  th:field="${group.status}">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">排序</label>
				<div class="layui-input-inline">
					<input type="text" name="sort" placeholder="请输入排序"  th:value="${group.sort}"
						class="layui-input">
				</div>
			</div>


			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-normal" lay-submit
						lay-filter="saveBtn">确认保存</button>
				</div>
			</div>
		</div>
<!-- 	</form> -->
	<script th:src="@{/manager/layui/lib/layui-v2.5.5/layui.js}"
		src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
	<script>
		layui.use([ 'form' ], function() {
			var form = layui.form, layer = layui.layer, $ = layui.$;

			//监听提交
			form.on('submit(saveBtn)', function(data) {
				$.ajax({
					url: '/group/add',
					data: data.field,
					dataType:"json",
					success:function(result){
						if(result.code == 200){
							layer.alert("操作成功",function(){
								parent.window.location.reload();
							})
						}else{
							layer.alert("添加失败",function(index){
								layer.close(index);
							})
						}
					}
				});
// 				var index = layer.alert(JSON.stringify(data.field), {
// 					title : '最终的提交信息'
// 				}, function() {

// 					// 关闭弹出层
// 					layer.close(index);

// 					var iframeIndex = parent.layer.getFrameIndex(window.name);
// 					parent.layer.close(iframeIndex);

// 				});

				return false;
			});

		});
	</script>
</body>
</html>